package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IGoodsQueryServcice;
import com.mall.shopping.dto.ShowGoodsByPageRequest;
import com.mall.shopping.dto.ShowGoodsByPageResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author TL
 * @created Date:2020/12/20 Time:15:28
 **/
@RestController
@RequestMapping("shopping")
@Anoymous
public class GoodsSortController {
    @Reference(timeout = 3000,retries = 0, check = false)
    IGoodsQueryServcice iGoodsQueryServcice;

    @GetMapping("goods")
    public ResponseData showGoodsSortByPage(ShowGoodsByPageRequest request){
        ShowGoodsByPageResponse showGoodsByPageResponse = iGoodsQueryServcice.showGoodsSortByPage(request);
        Map<String,Object> object = new HashMap<>();
        object.put("data",showGoodsByPageResponse.getGoodsSortDtos());
        object.put("total",showGoodsByPageResponse.getTotal());
        return new ResponseUtil().setData(object);
    }
}
